<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>this指向</title>
</head>
<body>
    <script>
        // "use strict";
        var name = 'a';
        function fn(){
            var name = 'b';
            console.log(this.name);
        } 
        // fn(); // a

        let obj = {
            name: 'fog',
            fn: function() {
                console.log(this.name);
            }
        }
        // method
        obj.fn(); // fog
        // 最后指向
        const fn2 = obj.fn;
        fn2(); // a
    </script>
</body>
</html>